package com.project.service.impl;

import com.project.bean.ClassBean;
import com.project.mapper.IClassMapper;
import com.project.mapper.IStuMapper;
import com.project.service.IClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ClassServiceImpl implements IClassService {

    @Autowired
    private IClassMapper mapper;

    @Autowired
    private IStuMapper stuMapper;
    @Override
    public List<ClassBean> findAllClass() {
        return mapper.findAllClass();
    }

    @Override
    public void addClass(ClassBean newClass) {
        mapper.addClass(newClass);
    }

    @Override
    public boolean delClass(Integer classId) {
        if (stuMapper.findStuNumById(classId) != 0) {
            return false;
        }
        mapper.delClass(classId);
        return true;
    }
}
